package ru.amse.baltijsky.javascheme.importer;

import ru.amse.baltijsky.javascheme.tree.SchemaTree;

import java.io.IOException;
import java.io.Reader;

/**
 * Importer parses the given input sequence and produces internal representation in the terms of the
 * classes in <code>model</code> package.
 */
public interface IImporter {
    /**
     * Reads the input and creates schema tree for the specified function of the specified class.
     *
     * @param in         input from which the data is obtained
     * @param className  the name of the class for which to create the scheme
     * @param methodName the name of the method for which to create the scheme
     * @return the root of the constructed loadTree tree
     * @throws IOException if an input error occurred while parsing the given source code
     */
    public SchemaTree loadTree(Reader in, String className, String methodName) throws IOException;

    /**
     * Loads a bunch of trees reading the input.
     *
     * @param in input
     * @return bunch of schema trees generated from the input
     * @throws IOException if an error occurred while parsing the given input or if the tree could not be generated
     */
    public SchemaTree[] loadTrees(Reader in) throws IOException;

    /**
     * Returns the list of classes declared in the source code contained in the input reader.
     *
     * @param in the input reader
     * @return list of classes defined in the java source code contained in the input reader
     * @throws java.io.IOException if an error occurred while parsing the given input
     */
    public String[] getClasses(Reader in) throws IOException;

    /**
     * Returns the list of methods declared in the specified class in the java source file contained in the input reader.
     *
     * @param in        the input reader
     * @param className the name of the class to collect methods
     * @return list of methods
     * @throws java.io.IOException if an error occurred while parsing the given input or the class was not found
     */
    public String[] getMethods(Reader in, String className) throws IOException;

}
